//
//  TTPassDiamondParamsViewController.m
//  TaoTuo
//
//  Created by LG on 2020/8/10.
//  Copyright © 2020 刘广. All rights reserved.
//

#import "TTPassDiamondParamsViewController.h"
#import "TTFiltrateView.h"
#import "TTSendButtonView.h"
#import "TTEstimateDetailViewController.h"
#import "TTRecyclingValuationViewController.h"
#import "TTRecyclingSendViewController.h"

#define kFilterViewH 40

@interface TTPassDiamondParamsViewController ()<UITextFieldDelegate>
{
    UILabel *fiveLabel;
    TTFiltrateView *fiveFilterView1;
    TTFiltrateView *fiveFilterView2;
    TTFiltrateView *fiveFilterView3;
    TTFiltrateView *sixFilterView;
}

@property (nonatomic, strong) UIScrollView *scrollView;
@property (nonatomic, strong) UIView *whiteBGView;
@property (strong, nonatomic) UITextField *zlTF;
@property (strong, nonatomic) UIButton *optionalBtn;
@property (strong, nonatomic) UIView *optionalView;

@property (strong, nonatomic) NSMutableArray *titlesArray;
@property (strong, nonatomic) NSMutableDictionary *paramsDic;

@end

@implementation TTPassDiamondParamsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = UIColorHex(#F7F7F7);
    
    self.paramsDic = [NSMutableDictionary dictionary];
    
    [self setupSubviews];
    
}

// 人工估价
- (void)gotoManValuationClick
{
    TTRecyclingValuationViewController *recyclingVC = [[TTRecyclingValuationViewController alloc] init];
    [[LLRouteTool getCurrentNavigationController] pushViewController:recyclingVC animated:YES];
}

/// 直接寄送
- (void)sendBtnClick
{
    [self valuationPriceSuccess:^(NSString *infoID) {
        
        TTRecyclingSendViewController *sendVC = [[TTRecyclingSendViewController alloc] init];
        sendVC.Reclaim_InformationId = infoID;
        [[LLRouteTool getCurrentNavigationController] pushViewController:sendVC animated:YES];
        
    }];
    
    
}

/// 开始估价
- (void)startValuationBtnClick
{
    [self valuationPriceSuccess:^(NSString *infoID) {
        
        TTEstimateDetailViewController *detailVC = [[TTEstimateDetailViewController alloc] init];
        detailVC.Reclaim_InformationId = infoID;
        [[LLRouteTool getCurrentNavigationController] pushViewController:detailVC animated:YES];
        
    }];
    
}


- (void)valuationPriceSuccess:(void(^)(NSString *infoID))success
{
    if (_zlTF.text.length == 0) {
        [self.view makeToast:@"请输入克拉重量"];
        return;
    }
    if (self.titlesArray.count > 0) {
        [self.view makeToast:[NSString stringWithFormat:@"请选择 %@", self.titlesArray.firstObject]];
        return;
    }
    
    [self.paramsDic setObject:self.zlTF.text forKey:@"DiaSize"];
    [self.paramsDic setObject:[TTLoginSingle sharedSingle].loginModel.RealName forKey:@"RealName"];
    [self.paramsDic setObject:[TTLoginSingle sharedSingle].loginModel.SalesmanAccountName forKey:@"SalesmanAccountName"];
    [self.paramsDic setObject:[TTLoginSingle sharedSingle].loginModel.SalesmanMobile forKey:@"SalesmanMobile"];
    
    [MBProgressHUD showLoadingAnimationOnView:[UIApplication sharedApplication].keyWindow];
    @weakify(self)
    [[LLNetworkManagerTool sharedManager] postJsonWithUrlString:autoPrice_api parameters:self.paramsDic success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        @strongify(self)
        [MBProgressHUD dismissAnimationOnView:[UIApplication sharedApplication].keyWindow];
        success(responseObject[@"Reclaim_InformationId"]);
        
    } failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nullable error) {
        
        [MBProgressHUD dismissAnimationOnView:[UIApplication sharedApplication].keyWindow];
        
    } showLoadingInView:[UIApplication sharedApplication].keyWindow];
}


// 点击了可选按钮
- (void)clickOptionalBtn
{
    self.optionalBtn.hidden = YES;
    
    [self.whiteBGView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(self.optionalView.bottom);
    }];
    [self.view layoutIfNeeded];
    self.scrollView.contentSize = CGSizeMake(kScreenWidth, self.whiteBGView.bottom + 20);
}

- (void)textFieldDidEndEditing:(UITextField *)textField
{
    CGFloat count = textField.text.floatValue;
    if (count < 0.2) {
        self.zlTF.text = @"0.2";
    } else if (count > 30) {
        self.zlTF.text = @"30";
    }
}

- (void)setupSubviews
{
    self.titlesArray = [NSMutableArray array];
    
    self.scrollView = [[UIScrollView alloc] init];
    [self.view addSubview:self.scrollView];
    [self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self.view);
        make.bottom.equalTo(self.view).mas_offset(-70);
    }];
    
    NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:@" 没有钻石4C参数？请拍照上传，进行人工估价"];
    [attr addAttribute:NSForegroundColorAttributeName value:UIColorHex(#DE4747) range:[attr.string rangeOfString:@"人工估价"]];
    [attr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:[attr.string rangeOfAll]];
    
    UIButton *topBtn = [UIButton createButtonWithTitle:@"" titleColor:UIColorHex(#343434) titleFont:[UIFont systemFontOfSize:12] backgroundColor:nil target:self action:@selector(gotoManValuationClick)];
    [topBtn setImage:[UIImage imageNamed:@"hintgantanhao"] forState:UIControlStateNormal];
    [topBtn setAttributedTitle:attr forState:UIControlStateNormal];
    [self.scrollView addSubview:topBtn];
    [topBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.scrollView).mas_offset(8);
        make.left.mas_equalTo(30);
    }];
    
    _whiteBGView = [[UIView alloc] init];
    _whiteBGView.backgroundColor = [UIColor whiteColor];
    _whiteBGView.layer.cornerRadius = 8;
    _whiteBGView.clipsToBounds = YES;
    [self.scrollView addSubview:_whiteBGView];
    [_whiteBGView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(topBtn.mas_bottom).mas_offset(8);
        make.left.equalTo(self.view).mas_equalTo(15);
        make.right.equalTo(self.view).mas_offset(-15);
        make.height.mas_equalTo(kFilterViewH * 14 + 120);
    }];
    
    UILabel *zsInfoLabel = [UILabel labelWithTitle:@"钻石信息" color:UIColorHex(#333333) font:[UIFont boldSystemFontOfSize:18]];
    [_whiteBGView addSubview:zsInfoLabel];
    [zsInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(15);
        make.left.mas_equalTo(@13);
    }];
    
    UILabel *oneLabel = [UILabel labelWithTitle:@"1.形状" color:UIColorHex(#333333) fontSize:15];
    [_whiteBGView addSubview:oneLabel];
    [oneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(zsInfoLabel.mas_bottom).mas_offset(13);
        make.left.mas_equalTo(15);
    }];
    
    [self.view layoutIfNeeded];
    TTFiltrateView *oneFilterView = [self createFilterViewWithTop:oneLabel.bottom allowsMultiple:NO selectedArrayBlock:^(NSArray *selectArray) {
        NSLog(@">>> %ld,,, %@", selectArray.count, selectArray.firstObject);
        
        NSLog(@">>> %@", self->sixFilterView);
        if ([selectArray.firstObject isEqualToString:@"异形"]) {
            
            self->fiveLabel.text = @"5.抛光/对称 等级";
            self->fiveFilterView3.top = self->fiveFilterView2.top;
            self->fiveFilterView2.top = self->fiveFilterView1.top;
            
            self.optionalView.top = self->fiveFilterView3.bottom + 8;
            self->fiveFilterView1.hidden = YES;
            [self->fiveFilterView1 resetView];
            
            [self.paramsDic setObject:@"PRINCESS" forKey:@"Shape"];
            
        } else {
            
            self->fiveLabel.text = @"5.切工/抛光/对称 等级";
            self->fiveFilterView2.top = self->fiveFilterView1.bottom-5;
            self->fiveFilterView3.top = self->fiveFilterView2.bottom-5;
            
            self.optionalView.top = self->fiveFilterView3.bottom + 8;
            self->fiveFilterView1.hidden = NO;
            
            [self.paramsDic setObject:@"ROUND" forKey:@"Shape"];
            
        }
        
        UIView *view = self.optionalBtn.hidden ? self.optionalView : self.optionalBtn;
        self.optionalBtn.top = self.optionalView.top + self->sixFilterView.bottom;
        [self.whiteBGView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(view.bottom);
        }];
        
    }];
    [oneFilterView setDataArray:@[@"圆形", @"异形"]];
    [_whiteBGView addSubview:oneFilterView];
    
    
    UILabel *twoLabel = [UILabel labelWithTitle:@"2.克拉重量" color:UIColorHex(#333333) fontSize:15];
    [_whiteBGView addSubview:twoLabel];
    [twoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(oneFilterView.mas_bottom).mas_offset(8);
        make.left.mas_equalTo(15);
    }];
    UILabel *tfRightLabel = [UILabel labelWithTitle:@"ct" color:UIColorHex(#333333) fontSize:15];
    tfRightLabel.frame = CGRectMake(0, 0, 30, 30);
    _zlTF = [[UITextField alloc] init];
    _zlTF.placeholder = @"例如：0.3";
    _zlTF.font = [UIFont systemFontOfSize:12];
    _zlTF.keyboardType = UIKeyboardTypeDecimalPad;
    _zlTF.rightView = tfRightLabel;
    _zlTF.rightViewMode = UITextFieldViewModeAlways;
    _zlTF.delegate = self;
    [self.scrollView addSubview:_zlTF];
    [_zlTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(twoLabel.mas_bottom);
        make.left.equalTo(twoLabel).mas_offset(10);
        make.height.mas_equalTo(30);
        make.width.mas_equalTo(150);
    }];
    [self.view layoutIfNeeded];
    [LLLineUtilies addLineInView:_zlTF startPoint:CGPointMake(0, _zlTF.height - 1) endPoint:CGPointMake(_zlTF.width - 30, _zlTF.height - 1) lineColor:UIColorHex(#979797)];
    
    UILabel *threeLabel = [UILabel labelWithTitle:@"3.颜色等级" color:UIColorHex(#333333) fontSize:15];
    [_whiteBGView addSubview:threeLabel];
    [threeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.zlTF.mas_bottom).mas_offset(8);
        make.left.mas_equalTo(15);
    }];
    [self.view layoutIfNeeded];
    TTFiltrateView *threeFilterView = [self createFilterViewWithTop:threeLabel.bottom allowsMultiple:NO selectedArrayBlock:^(NSArray *selectArray) {
        
        [self.paramsDic setObject:selectArray.firstObject forKey:@"Color"];
        [self.titlesArray removeObject:threeLabel.text];
    }];
    [threeFilterView setDataArray:@[@"D", @"E", @"F", @"G", @"H", @"I", @"J", @"K", @"L", @"M", @"N", @"<N"]];
    threeFilterView.canCancelSelect = NO;
    [_whiteBGView addSubview:threeFilterView];
    
    
    
    UILabel *fourLabel = [UILabel labelWithTitle:@"4.净度等级" color:UIColorHex(#333333) fontSize:15];
    [_whiteBGView addSubview:fourLabel];
    [fourLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(threeFilterView.mas_bottom).mas_offset(8);
        make.left.mas_equalTo(15);
    }];
    [self.view layoutIfNeeded];
    TTFiltrateView *fourFilterView = [self createFilterViewWithTop:fourLabel.bottom allowsMultiple:NO selectedArrayBlock:^(NSArray *selectArray) {
        [self.paramsDic setObject:selectArray.firstObject forKey:@"Clarity"];
        [self.titlesArray removeObject:fourLabel.text];
    }];
    [fourFilterView setDataArray:@[@"IF", @"VVS1", @"VVS2", @"VS1", @"VS2", @"SI1", @"SI2", @"SI3", @"I1", @"I2", @"I3", @"FL"]];
    fourFilterView.canCancelSelect = NO;
    [_whiteBGView addSubview:fourFilterView];
    
    
    
    fiveLabel = [UILabel labelWithTitle:@"5.切工/抛光/对称 等级" color:UIColorHex(#333333) fontSize:15];
    [_whiteBGView addSubview:fiveLabel];
    [fiveLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(fourFilterView.mas_bottom).mas_offset(8);
        make.left.mas_equalTo(15);
    }];
    [self.view layoutIfNeeded];
    fiveFilterView1 = [self createFilterViewWithTop:fiveLabel.bottom allowsMultiple:NO selectedArrayBlock:^(NSArray *selectArray) {
        if (selectArray.count == 0) {
            [self.paramsDic removeObjectForKey:@"Cut"];
        } else {
            [self.paramsDic setObject:selectArray.firstObject forKey:@"Cut"];
        }
        [self.titlesArray removeObject:@"切工等级"];
    }];
    [fiveFilterView1 setDataArray:@[@"EX", @"VG", @"GD", @"FR", @"PR"]];
    fiveFilterView1.canCancelSelect = NO;
    [_whiteBGView addSubview:fiveFilterView1];
    fiveFilterView2 = [self createFilterViewWithTop:fiveFilterView1.bottom-5 allowsMultiple:NO selectedArrayBlock:^(NSArray *selectArray) {
        [self.paramsDic setObject:selectArray.firstObject forKey:@"Polish"];
        [self.titlesArray removeObject:@"抛光等级"];
    }];
    [fiveFilterView2 setDataArray:@[@"EX", @"VG", @"GD", @"FR", @"PR"]];
    fiveFilterView2.canCancelSelect = NO;
    [_whiteBGView insertSubview:fiveFilterView2 belowSubview:fiveFilterView1];
    fiveFilterView3 = [self createFilterViewWithTop:fiveFilterView2.bottom-5 allowsMultiple:NO selectedArrayBlock:^(NSArray *selectArray) {
        if (selectArray.count == 0) {
            [self.paramsDic removeObjectForKey:@"Sym"];
        } else {
            [self.paramsDic setObject:selectArray.firstObject forKey:@"Sym"];
        }
        [self.titlesArray removeObject:@"对称等级"];
    }];
    [fiveFilterView3 setDataArray:@[@"EX", @"VG", @"GD", @"FR", @"PR"]];
    fiveFilterView3.canCancelSelect = NO;
    [_whiteBGView insertSubview:fiveFilterView3 belowSubview:fiveFilterView2];
    
    _optionalView = [[UIView alloc] initWithFrame:CGRectMake(0, fiveFilterView3.bottom + 8, _whiteBGView.width, kFilterViewH * 12)];
    _optionalView.backgroundColor = [UIColor whiteColor];
    [_whiteBGView addSubview:_optionalView];
    
    UILabel *sixLabel = [UILabel labelWithTitle:@"6.荧光" color:UIColorHex(#333333) fontSize:15];
    [_optionalView addSubview:sixLabel];
    [sixLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.left.mas_equalTo(15);
    }];
    [self.view layoutIfNeeded];
    sixFilterView = [self createFilterViewWithTop:sixLabel.bottom allowsMultiple:NO selectedArrayBlock:^(NSArray *selectArray) {
        NSString *str = [selectArray.firstObject isEqualToString:@"无"] ? @"N" : @"";
        [self.paramsDic setObject:str forKey:@"Flour"];
        [self.titlesArray removeObject:sixLabel.text];
    }];
    [sixFilterView setDataArray:@[@"无", @"有"]];
    sixFilterView.canCancelSelect = NO;
    [_optionalView addSubview:sixFilterView];
    
    UILabel *sevenLabel = [UILabel labelWithTitle:@"7.肉眼净(可选)" color:UIColorHex(#333333) fontSize:15];
    sevenLabel.attributedText = [self getAttrString:sevenLabel.text];
    [_optionalView addSubview:sevenLabel];
    [sevenLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(sixFilterView.mas_bottom).mas_offset(8);
        make.left.mas_equalTo(15);
    }];
    [self.view layoutIfNeeded];
    TTFiltrateView *sevenFilterView = [self createFilterViewWithTop:sevenLabel.bottom allowsMultiple:NO selectedArrayBlock:^(NSArray *selectArray) {
        if (selectArray.count > 0) {
            int i = [selectArray.firstObject isEqualToString:@"是"] ? 1 : 0;
            [self.paramsDic setObject:@(i) forKey:@"EyeClean"];
        } else {
            [self.paramsDic removeObjectForKey:@"EyeClean"];
        }
        
    }];
    [sevenFilterView setDataArray:@[@"是", @"否"]];
    [_optionalView addSubview:sevenFilterView];
    
    
    
    UILabel *eightLabel = [UILabel labelWithTitle:@"8.奶色(可选)" color:UIColorHex(#333333) fontSize:15];
    eightLabel.attributedText = [self getAttrString:eightLabel.text];
    [_optionalView addSubview:eightLabel];
    [eightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(sevenFilterView.mas_bottom).mas_offset(8);
        make.left.mas_equalTo(15);
    }];
    [self.view layoutIfNeeded];
    TTFiltrateView *eightFilterView = [self createFilterViewWithTop:eightLabel.bottom allowsMultiple:NO selectedArrayBlock:^(NSArray *selectArray) {
        if (selectArray.count > 0) {
            NSString *str = [selectArray.firstObject isEqualToString:@"无奶"] ? @"N" : @"";
            if (str.length > 0) {
                [self.paramsDic setObject:str forKey:@"Milky"];
            } else {
                [self.paramsDic removeObjectForKey:@"Milky"];
            }
        } else {
            [self.paramsDic removeObjectForKey:@"Milky"];
        }
    }];
    [eightFilterView setDataArray:@[@"无奶", @"有奶"]];
    [_optionalView addSubview:eightFilterView];
    
    
    
    UILabel *nineLabel = [UILabel labelWithTitle:@"9.咖色(可选)" color:UIColorHex(#333333) fontSize:15];
    nineLabel.attributedText = [self getAttrString:nineLabel.text];
    [_optionalView addSubview:nineLabel];
    [nineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(eightFilterView.mas_bottom).mas_offset(8);
        make.left.mas_equalTo(15);
    }];
    [self.view layoutIfNeeded];
    TTFiltrateView *nineFilterView = [self createFilterViewWithTop:nineLabel.bottom allowsMultiple:NO selectedArrayBlock:^(NSArray *selectArray) {
        if (selectArray.count > 0) {
            NSString *str = [selectArray.firstObject isEqualToString:@"无咖"] ? @"N" : @"";
            if (str.length > 0) {
                [self.paramsDic setObject:str forKey:@"Browness"];
            } else {
                [self.paramsDic removeObjectForKey:@"Browness"];
            }
        } else {
            [self.paramsDic removeObjectForKey:@"Browness"];
        }
    }];
    [nineFilterView setDataArray:@[@"无咖", @"有咖"]];
    [_optionalView addSubview:nineFilterView];
    
    
    UILabel *tenLabel = [UILabel labelWithTitle:@"10.绿色(可选)" color:UIColorHex(#333333) fontSize:15];
    tenLabel.attributedText = [self getAttrString:tenLabel.text];
    [_optionalView addSubview:tenLabel];
    [tenLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(nineFilterView.mas_bottom).mas_offset(8);
        make.left.mas_equalTo(15);
    }];
    [self.view layoutIfNeeded];
    TTFiltrateView *tenFilterView = [self createFilterViewWithTop:tenLabel.bottom allowsMultiple:NO selectedArrayBlock:^(NSArray *selectArray) {
        if (selectArray.count > 0) {
            NSString *str = [selectArray.firstObject isEqualToString:@"无绿"] ? @"N" : @"";
            if (str.length > 0) {
                [self.paramsDic setObject:str forKey:@"Green"];
            } else {
                [self.paramsDic removeObjectForKey:@"Green"];
            }
        } else {
            [self.paramsDic removeObjectForKey:@"Green"];
        }
    }];
    [tenFilterView setDataArray:@[@"无绿", @"有绿"]];
    [_optionalView addSubview:tenFilterView];
    
    
    UILabel *elevenLabel = [UILabel labelWithTitle:@"11.黑色(可选)" color:UIColorHex(#333333) fontSize:15];
    elevenLabel.attributedText = [self getAttrString:elevenLabel.text];
    [_optionalView addSubview:elevenLabel];
    [elevenLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(tenFilterView.mas_bottom).mas_offset(8);
        make.left.mas_equalTo(15);
    }];
    [self.view layoutIfNeeded];
    TTFiltrateView *elevenFilterView = [self createFilterViewWithTop:elevenLabel.bottom allowsMultiple:NO selectedArrayBlock:^(NSArray *selectArray) {
        if (selectArray.count > 0) {
            NSString *str = [selectArray.firstObject isEqualToString:@"无黑"] ? @"N" : @"";
            if (str.length > 0) {
                [self.paramsDic setObject:str forKey:@"Black"];
            } else {
                [self.paramsDic removeObjectForKey:@"Black"];
            }
        } else {
            [self.paramsDic removeObjectForKey:@"Black"];
        }
    }];
    [elevenFilterView setDataArray:@[@"无黑", @"有黑"]];
    [_optionalView addSubview:elevenFilterView];
    
    
    [self.view layoutIfNeeded];
    
    [oneFilterView setSelectedFirstItem];
    [self.titlesArray addObjectsFromArray:@[threeLabel.text, fourLabel.text, @"切工等级", @"抛光等级", @"对称等级", sixLabel.text]];
    
    _optionalBtn = [UIButton createButtonImageBottomWithFrame:CGRectMake(0, _optionalView.top + sixFilterView.bottom, _whiteBGView.width, 70) image:[UIImage imageNamed:@"down"] title:@"其他参数(可选)" titleColor:UIColorHex(#666666) titleFont:[UIFont systemFontOfSize:15] backgroundColor:[UIColor whiteColor] target:self action:@selector(clickOptionalBtn)];
    [_whiteBGView addSubview:_optionalBtn];
    
    [self.whiteBGView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(_optionalBtn.bottom);
    }];
    [self.view layoutIfNeeded];
    self.scrollView.contentSize = CGSizeMake(kScreenWidth, self.whiteBGView.bottom + 20);
    
    @weakify(self)
    TTSendButtonView *btnView = [TTSendButtonView createSendButtonViewAndClickSendButtonBlock:^{
        @strongify(self)
        [self sendBtnClick];
    } startValuationBtnBlock:^{
        @strongify(self)
        [self startValuationBtnClick];
    }];
    [btnView setButtonEnabled:YES];
    [self.view addSubview:btnView];
    [btnView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.scrollView.mas_bottom).mas_offset(10);
        make.height.equalTo(@40);
        make.left.equalTo(@15);
        make.right.equalTo(@-15);
    }];
    
    
}

- (TTFiltrateView *)createFilterViewWithTop:(CGFloat)top allowsMultiple:(BOOL)allowsMultiple selectedArrayBlock:(void(^)(NSArray * selectArray))selectedArrayBlock
{
    TTFiltrateView *filterView = [[TTFiltrateView alloc] initWithFrame:CGRectMake(8, top, _whiteBGView.width - 20, kFilterViewH) allowsMultiple:NO selectedArrayBlock:^(NSArray * _Nullable selectedArray) {
        
        if (selectedArrayBlock) {
            selectedArrayBlock(selectedArray);
        }
        
    } leftRightSpace:0 cornerRadius:3];
    filterView.normalTitleColor = UIColorHex(#9445EB);
    filterView.selectedTitleColor = [UIColor whiteColor];
    filterView.normalBackgroundColor = [UIColor whiteColor];
    filterView.selectedBackgroundColor = UIColorHex(#9445EB);
    filterView.boardWidth = 0.5;
    filterView.boardColor = UIColorHex(#9445EB);
    
//    [filterView setFixWidthAndHeight:CGSizeMake(50, 25)];
    [filterView setLayoutConfigWithMinimumLineSpacing:3 minimumInteritemSpacing:3 sectionInset:UIEdgeInsetsMake(5, 10, 0, 0)];
    
    return filterView;
}

- (NSMutableAttributedString *)getAttrString:(NSString *)str
{
    NSRange range = [str rangeOfString:@"(可选)"];
    if (range.location != NSNotFound) {
        NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:str];
        [attr addAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:12], NSForegroundColorAttributeName : UIColorHex(#999999)} range:range];
        return attr;
    }
    return nil;
}


- (UIView *)listView
{
    return self.view;
}

@end
